package com.example.springbootexamples.controller;

import com.example.springbootexamples.domain.L1;
import com.example.springbootexamples.domain.THelloWorld;
import com.example.springbootexamples.service.HelloService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;


@RestController
public class HelloController {

    private Logger logger= LoggerFactory.getLogger(this.getClass());
    
    @Autowired
    private HelloService helloService;

    @RequestMapping("hello/selectById")
    public THelloWorld selectById(Long id) {
        return helloService.selectById(id);
    }

    @RequestMapping("hello/selectList")
    public List<THelloWorld> selectList(THelloWorld tHelloWorld) {
        return helloService.selectList(tHelloWorld);
    }

    @RequestMapping(value = "hello/insert",method = RequestMethod.POST)
    public int insert(THelloWorld tHelloWorld) {
        return helloService.insert(tHelloWorld);
    }

    @RequestMapping(value = "hello/insertList",method = RequestMethod.POST)
    public int insertList(List<THelloWorld> list) {
        return helloService.insertList(list);
    }

    @RequestMapping(value = "hello/update",method = RequestMethod.POST)
    public int update(THelloWorld tHelloWorld) {
        return helloService.update(tHelloWorld);
    }

    @RequestMapping(value = "hello/deleteById",method = RequestMethod.POST)
    public int deleteById(Long id) {
        return helloService.deleteById(id);
    }

    @RequestMapping(value = "hello/deleteByIds",method = RequestMethod.POST)
    public int deleteByIds(String[] ids) {
        return helloService.deleteByIds(ids);
    }
    
    /*@RequestMapping(value = "hello",method = RequestMethod.GET)
    public L1 hello(@ApiParam("aa") L1 l1 ){
        System.out.println(atomicInteger.addAndGet(1));
        try {
            Thread.sleep(1000*60*60);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println(this);
        helloService.hello("a");
        return null;
    }*/

}
